import 'base_presenter.dart';
import 'package:flutterclue/utils/SharePreferensUtil.dart';
import 'package:flutterclue/http_util/constant_url.dart';
import 'package:flutterclue/mvp/mode/ClueListBean.dart';

class ClueListPagePresenter extends ClueBasePresenter<ClueListPageView> {
  getClueListData(int timeType, int pageIndex,int clueState) async {
    baseView.showLoadingView();
    Map<String, Object> map = new Map();
    map["AgentId"] =
        await SharePreferencesUtil.getString(SharePreferencesUtil.AgentId);
    map["TopAgentId"] =
        await SharePreferencesUtil.getString(SharePreferencesUtil.TopAgentId);
    map["TimeType"] = "${timeType}";
    map["PageSize"] = "15";
    map["PageIndex"] = "$pageIndex";
    map["RoleType"] = "${await SharePreferencesUtil.getInt(SharePreferencesUtil.RoleType)}";
    map["ClueState"]="${clueState}";
    await postData(
        url: ApiUrl.Clue_Accident_List,
        params: map,
        error: (error) {
          baseView.dismissLoadingView();
          baseView.onFail(error.toString() == null ? "数据为空" : error.toString());
        }).then((bean) {
      baseView.dismissLoadingView();
      if (bean.Code == 1) {
        ClueListBean clueListBean = ClueListBean.fromJson(bean.Data);
        baseView.onSuccessData(clueListBean);
      } else {
        baseView.onFail(bean.Message == null ? "数据为空" : bean.Message);
      }
    });
  }
}

abstract class ClueListPageView extends BaseView {
  void onFail(String s);

  void onSuccessData(ClueListBean clueDetailBean);
}
